/*
 * Ext JS Library 3.0 RC2
 * Copyright(c) 2006-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */


Ext.layout.ToolbarLayout=Ext.extend(Ext.layout.ContainerLayout,{monitorResize:true,triggerWidth:18,lastOverflow:false,noItemsMenuText:'<div class="x-toolbar-no-items">(None)</div>',onLayout:function(ct,target){if(!this.leftTr){target.addClass('x-toolbar-layout-ct');target.insertHtml('beforeEnd','<table cellspacing="0" class="x-toolbar-ct"><tbody><tr><td class="x-toolbar-left" align="left"><table cellspacing="0"><tbody><tr class="x-toolbar-left-row"></tr></tbody></table></td><td class="x-toolbar-right" align="right"><table cellspacing="0" class="x-toolbar-right-ct"><tbody><tr><td><table cellspacing="0"><tbody><tr class="x-toolbar-right-row"></tr></tbody></table></td><td><table cellspacing="0"><tbody><tr class="x-toolbar-extras-row"></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>');this.leftTr=target.child('tr.x-toolbar-left-row',true);this.rightTr=target.child('tr.x-toolbar-right-row',true);this.extrasTr=target.child('tr.x-toolbar-extras-row',true);}
var side=this.leftTr;var pos=0;var items=ct.items.items;for(var i=0,len=items.length,c;i<len;i++,pos++){c=items[i];if(c.isFill){side=this.rightTr;pos=-1;}else if(!c.rendered){c.render(this.insertCell(c,side,pos));}else{if(!c.xtbHidden&&!this.isValidParent(c,side.childNodes[pos])){var td=this.insertCell(c,side,pos);td.appendChild(c.getDomPositionEl().dom);c.container=Ext.get(td);}}}
this.cleanup(this.leftTr);this.cleanup(this.rightTr);this.cleanup(this.extrasTr);this.fitToSize(target);},cleanup:function(row){var cn=row.childNodes;for(var i=cn.length-1,c;i>=0&&(c=cn[i]);i--){if(!c.firstChild){row.removeChild(c);}}},insertCell:function(c,side,pos){var td=document.createElement('td');td.className='x-toolbar-cell';side.insertBefore(td,side.childNodes[pos]||null);return td;},hideItem:function(item){var h=(this.hiddens=this.hiddens||[]);h.push(item);item.xtbHidden=true;item.xtbWidth=item.getDomPositionEl().dom.parentNode.offsetWidth;item.hide();},unhideItem:function(item){item.show();item.xtbHidden=false;this.hiddens.remove(item);if(this.hiddens.length<1){delete this.hiddens;}},getItemWidth:function(c){return c.hidden?(c.xtbWidth||0):c.getDomPositionEl().dom.parentNode.offsetWidth;},fitToSize:function(t){if(this.container.enableOverflow===false){return;}
var w=t.dom.clientWidth;var lw=this.lastWidth||0;this.lastWidth=w;var iw=t.dom.firstChild.offsetWidth;var clipWidth=w-this.triggerWidth;var hideIndex=-1;if(iw>w||(this.hiddens&&w>=lw)){var i,items=this.container.items.items,len=items.length,c;var loopWidth=0;for(i=0;i<len;i++){c=items[i];if(!c.isFill){loopWidth+=this.getItemWidth(c);if(loopWidth>clipWidth){if(!c.xtbHidden){this.hideItem(c);}}else{if(c.xtbHidden){this.unhideItem(c);}}}}}
if(this.hiddens){this.initMore();if(!this.lastOverflow){this.container.fireEvent('overflowchange',this.container,true);this.lastOverflow=true;}}else if(this.more){this.clearMenu();this.more.destroy();delete this.more;if(this.lastOverflow){this.container.fireEvent('overflowchange',this.container,false);this.lastOverflow=false;}}},createMenuConfig:function(c,hideOnClick){var cfg=Ext.apply({},c.initialConfig),group=c.toggleGroup;Ext.apply(cfg,{text:c.overflowText||c.text,iconCls:c.iconCls,icon:c.icon,itemId:c.itemId,disabled:c.disabled,handler:c.handler,scope:c.scope,menu:c.menu,hideOnClick:hideOnClick});if(group||c.enableToggle){Ext.apply(cfg,{group:group,checked:c.pressed,listeners:{checkchange:function(item,checked){c.toggle(checked);}}});}
delete cfg.xtype;delete cfg.id;return cfg;},addComponentToMenu:function(m,c){if(c instanceof Ext.Toolbar.Separator){m.add('-');}else if(Ext.isFunction(c.isXType)){if(c.isXType('splitbutton')){m.add(this.createMenuConfig(c,true));}else if(c.isXType('button')){m.add(this.createMenuConfig(c,!c.menu));}else if(c.isXType('buttongroup')){m.add('-');c.items.each(function(item){this.addComponentToMenu(m,item);},this);m.add('-');}}},clearMenu:function(){var m=this.moreMenu;if(m&&m.items){this.moreMenu.items.each(function(item){delete item.menu;});}},beforeMoreShow:function(m){this.clearMenu();m.removeAll();for(var i=0,h=this.container.items.items,len=h.length,c;i<len;i++){c=h[i];if(c.xtbHidden){this.addComponentToMenu(m,c);}}
if(m.items.length<1){m.add(this.noItemsMenuText);}},initMore:function(){if(!this.more){this.moreMenu=new Ext.menu.Menu({listeners:{beforeshow:this.beforeMoreShow,scope:this}});this.more=new Ext.Button({iconCls:'x-toolbar-more-icon',cls:'x-toolbar-more',menu:this.moreMenu});var td=this.insertCell(this.more,this.extrasTr,100);this.more.render(td);}},destroy:function(){Ext.destroy(this.more,this.moreMenu);Ext.layout.ToolbarLayout.superclass.destroy.call(this);}});Ext.Container.LAYOUTS['toolbar']=Ext.layout.ToolbarLayout;Ext.Toolbar=function(config){if(Ext.isArray(config)){config={items:config,layout:'toolbar'};}else{config=Ext.apply({layout:'toolbar'},config);if(config.buttons){config.items=config.buttons;}}
Ext.Toolbar.superclass.constructor.call(this,config);};(function(){var T=Ext.Toolbar;Ext.extend(T,Ext.Container,{defaultType:'button',trackMenus:true,internalDefaults:{removeMode:'container',hideParent:true},toolbarCls:'x-toolbar',initComponent:function(){T.superclass.initComponent.call(this);this.addEvents('overflowchange');},onRender:function(ct,position){if(!this.el){if(!this.autoCreate){this.autoCreate={cls:this.toolbarCls+' x-small-editor'}}
this.el=ct.createChild(Ext.apply({id:this.id},this.autoCreate),position);}},add:function(){Ext.Toolbar.superclass.add.apply(this,arguments);},lookupComponent:function(c){if(typeof c=='string'){if(c=='-'){c=new T.Separator();}else if(c==' '){c=new T.Spacer();}else if(c=='->'){c=new T.Fill();}else{c=new T.TextItem(c);}
this.applyDefaults(c);}else{if(c.isFormField||c.render){c=this.constructItem(c);}else if(c.tag){c=new T.Item({autoEl:c});}else if(c.tagName){c=new T.Item({el:c});}else if(Ext.isObject(c)){c=c.xtype?this.constructItem(c):this.constructButton(c);}}
return c;},applyDefaults:function(c){if(typeof c!='string'){c=Ext.Toolbar.superclass.applyDefaults.call(this,c);var d=this.internalDefaults;if(c.events){Ext.applyIf(c.initialConfig,d);Ext.apply(c,d);}else{Ext.applyIf(c,d);}}
return c;},constructItem:function(item){return Ext.create(item,'button');},addSeparator:function(){return this.add(new T.Separator());},addSpacer:function(){return this.add(new T.Spacer());},addFill:function(){this.add(new T.Fill());},addElement:function(el){return this.addItem(new T.Item({el:el}));},addItem:function(item){return Ext.Toolbar.superclass.add.apply(this,arguments);},addButton:function(config){if(Ext.isArray(config)){var buttons=[];for(var i=0,len=config.length;i<len;i++){buttons.push(this.addButton(config[i]));}
return buttons;}
return this.add(this.constructButton(config));},addText:function(text){return this.addItem(new T.TextItem(text));},addDom:function(config){return this.add(new T.Item({autoEl:config}));},addField:function(field){return this.add(field);},insertButton:function(index,item){if(Ext.isArray(item)){var buttons=[];for(var i=0,len=item.length;i<len;i++){buttons.push(this.insertButton(index+i,item[i]));}
return buttons;}
return Ext.Toolbar.superclass.insert.call(this,index,item);},initMenuTracking:function(item){if(this.trackMenus&&item.menu){this.mon(item,{'menutriggerover':this.onButtonTriggerOver,'menushow':this.onButtonMenuShow,'menuhide':this.onButtonMenuHide,scope:this});}},constructButton:function(item){var b=item.events?item:this.constructItem(item);this.initMenuTracking(b);return b;},onDisable:function(){this.items.each(function(item){if(item.disable){item.disable();}});},onEnable:function(){this.items.each(function(item){if(item.enable){item.enable();}});},onButtonTriggerOver:function(btn){if(this.activeMenuBtn&&this.activeMenuBtn!=btn){this.activeMenuBtn.hideMenu();btn.showMenu();this.activeMenuBtn=btn;}},onButtonMenuShow:function(btn){this.activeMenuBtn=btn;},onButtonMenuHide:function(btn){delete this.activeMenuBtn;}});Ext.reg('toolbar',Ext.Toolbar);T.Item=Ext.extend(Ext.BoxComponent,{hideParent:true,enable:Ext.emptyFn,disable:Ext.emptyFn,focus:Ext.emptyFn});Ext.reg('tbitem',T.Item);T.Separator=Ext.extend(T.Item,{onRender:function(ct,position){this.el=ct.createChild({tag:'span',cls:'xtb-sep'},position);}});Ext.reg('tbseparator',T.Separator);T.Spacer=Ext.extend(T.Item,{onRender:function(ct,position){this.el=ct.createChild({tag:'div',cls:'xtb-spacer',style:this.width?'width:'+this.width+'px':''},position);}});Ext.reg('tbspacer',T.Spacer);T.Fill=Ext.extend(T.Item,{render:Ext.emptyFn,isFill:true});Ext.reg('tbfill',T.Fill);T.TextItem=Ext.extend(T.Item,{constructor:function(config){if(typeof config=='string'){config={autoEl:{cls:'xtb-text',html:config}};}else{config.autoEl={cls:'xtb-text',html:config.text||''};}
T.TextItem.superclass.constructor.call(this,config);},setText:function(t){if(this.rendered){this.el.dom.innerHTML=t;}else{this.autoEl.html=t;}}});Ext.reg('tbtext',T.TextItem);T.Button=Ext.extend(Ext.Button,{});T.SplitButton=Ext.extend(Ext.SplitButton,{});Ext.reg('tbbutton',T.Button);Ext.reg('tbsplit',T.SplitButton);})();Ext.ButtonGroup=Ext.extend(Ext.Panel,{baseCls:'x-btn-group',layout:'table',defaultType:'button',frame:true,internalDefaults:{removeMode:'container',hideParent:true},initComponent:function(){this.layoutConfig=this.layoutConfig||{};Ext.applyIf(this.layoutConfig,{columns:this.columns});if(!this.title){this.addClass('x-btn-group-notitle');}
this.on('afterlayout',this.onAfterLayout,this);Ext.ButtonGroup.superclass.initComponent.call(this);},applyDefaults:function(c){c=Ext.ButtonGroup.superclass.applyDefaults.call(this,c);var d=this.internalDefaults;if(c.events){Ext.applyIf(c.initialConfig,d);Ext.apply(c,d);}else{Ext.applyIf(c,d);}
return c;},onAfterLayout:function(){var bodyWidth=this.body.getFrameWidth('lr')+this.body.dom.firstChild.offsetWidth;this.body.setWidth(bodyWidth);this.el.setWidth(bodyWidth+this.getFrameWidth());}});Ext.reg('buttongroup',Ext.ButtonGroup);

(function(){var T=Ext.Toolbar;Ext.PagingToolbar=Ext.extend(Ext.Toolbar,{pageSize:20,displayMsg:'Displaying {0} - {1} of {2}',emptyMsg:'No data to display',beforePageText:"Page",afterPageText:"of {0}",firstText:"First Page",prevText:"Previous Page",nextText:"Next Page",lastText:"Last Page",refreshText:"Refresh",paramNames:{start:'start',limit:'limit'},initComponent:function(){var pagingItems=[this.first=new T.Button({tooltip:this.firstText,iconCls:"x-tbar-page-first",disabled:true,handler:this.onClick,scope:this}),this.prev=new T.Button({tooltip:this.prevText,iconCls:"x-tbar-page-prev",disabled:true,handler:this.onClick,scope:this}),'-',this.beforePageText,this.inputItem=new T.Item({height:18,autoEl:{tag:"input",type:"text",size:"3",value:"1",cls:"x-tbar-page-number"}}),this.afterTextItem=new T.TextItem({text:String.format(this.afterPageText,1)}),'-',this.next=new T.Button({tooltip:this.nextText,iconCls:"x-tbar-page-next",disabled:true,handler:this.onClick,scope:this}),this.last=new T.Button({tooltip:this.lastText,iconCls:"x-tbar-page-last",disabled:true,handler:this.onClick,scope:this}),'-',this.refresh=new T.Button({tooltip:this.refreshText,iconCls:"x-tbar-loading",handler:this.onClick,scope:this})];var userItems=this.items||this.buttons||[];if(this.prependButtons){this.items=userItems.concat(pagingItems);}else{this.items=pagingItems.concat(userItems);}
delete this.buttons;if(this.displayInfo){this.items.push('->');this.items.push(this.displayItem=new T.TextItem({}));}
Ext.PagingToolbar.superclass.initComponent.call(this);this.addEvents('change','beforechange');this.on('afterlayout',this.onFirstLayout,this,{single:true});this.cursor=0;this.bindStore(this.store);},onFirstLayout:function(ii){this.mon(this.inputItem.el,"keydown",this.onPagingKeyDown,this);this.mon(this.inputItem.el,"blur",this.onPagingBlur,this);this.mon(this.inputItem.el,"focus",this.onPagingFocus,this);this.field=this.inputItem.el.dom;if(this.dsLoaded){this.onLoad.apply(this,this.dsLoaded);}},updateInfo:function(){if(this.displayItem){var count=this.store.getCount();var msg=count==0?this.emptyMsg:String.format(this.displayMsg,this.cursor+1,this.cursor+count,this.store.getTotalCount());this.displayItem.setText(msg);}},onLoad:function(store,r,o){if(!this.rendered){this.dsLoaded=[store,r,o];return;}
this.cursor=(o.params&&o.params[this.paramNames.start])?o.params[this.paramNames.start]:0;var d=this.getPageData(),ap=d.activePage,ps=d.pages;this.afterTextItem.setText(String.format(this.afterPageText,d.pages));this.field.value=ap;this.first.setDisabled(ap==1);this.prev.setDisabled(ap==1);this.next.setDisabled(ap==ps);this.last.setDisabled(ap==ps);this.refresh.enable();this.updateInfo();this.fireEvent('change',this,d);},getPageData:function(){var total=this.store.getTotalCount();return{total:total,activePage:Math.ceil((this.cursor+this.pageSize)/this.pageSize),pages:total<this.pageSize?1:Math.ceil(total/this.pageSize)};},changePage:function(page){this.doLoad(((page-1)*this.pageSize).constrain(0,this.store.getTotalCount()));},onLoadError:function(){if(!this.rendered){return;}
this.refresh.enable();},readPage:function(d){var v=this.field.value,pageNum;if(!v||isNaN(pageNum=parseInt(v,10))){this.field.value=d.activePage;return false;}
return pageNum;},onPagingFocus:function(){this.field.select();},onPagingBlur:function(e){this.field.value=this.getPageData().activePage;},onPagingKeyDown:function(e){var k=e.getKey(),d=this.getPageData(),pageNum;if(k==e.RETURN){e.stopEvent();pageNum=this.readPage(d);if(pageNum!==false){pageNum=Math.min(Math.max(1,pageNum),d.pages)-1;this.doLoad(pageNum*this.pageSize);}}else if(k==e.HOME||k==e.END){e.stopEvent();pageNum=k==e.HOME?1:d.pages;this.field.value=pageNum;}else if(k==e.UP||k==e.PAGEUP||k==e.DOWN||k==e.PAGEDOWN){e.stopEvent();if((pageNum=this.readPage(d))){var increment=e.shiftKey?10:1;if(k==e.DOWN||k==e.PAGEDOWN){increment*=-1;}
pageNum+=increment;if(pageNum>=1&pageNum<=d.pages){this.field.value=pageNum;}}}},beforeLoad:function(){if(this.rendered&&this.refresh){this.refresh.disable();}},doLoad:function(start){var o={},pn=this.paramNames;o[pn.start]=start;o[pn.limit]=this.pageSize;if(this.fireEvent('beforechange',this,o)!==false){this.store.load({params:o});}},onClick:function(button){var store=this.store;switch(button){case this.first:this.doLoad(0);break;case this.prev:this.doLoad(Math.max(0,this.cursor-this.pageSize));break;case this.next:this.doLoad(this.cursor+this.pageSize);break;case this.last:var total=store.getTotalCount();var extra=total%this.pageSize;var lastStart=extra?(total-extra):total-this.pageSize;this.doLoad(lastStart);break;case this.refresh:this.doLoad(this.cursor);break;}},bindStore:function(store,initial){if(!initial&&this.store){this.store.un("beforeload",this.beforeLoad,this);this.store.un("load",this.onLoad,this);this.store.un("loadexception",this.onLoadError,this);this.store.un("exception",this.onLoadError,this);if(store!==this.store&&this.store.autoDestroy){this.store.destroy();}}
if(store){store=Ext.StoreMgr.lookup(store);store.on({scope:this,beforeload:this.beforeLoad,load:this.onLoad,loadexception:this.onLoadError,exception:this.onLoadError});this.paramNames.start=store.paramNames.start;this.paramNames.limit=store.paramNames.limit;if(store.getCount()>0){this.onLoad(store,null,{});}}
this.store=store;},unbind:function(store){this.bindStore(null);},bind:function(store){this.bindStore(store);},onDestroy:function(){this.bindStore(null);Ext.PagingToolbar.superclass.onDestroy.call(this);}});})();Ext.reg('paging',Ext.PagingToolbar);
